#include <iostream>
#include <vector>
#include <cmath>

//https://www.nowcoder.com/questionTerminal/99fa7be28d5f4a9d9aa3c98a6a5b559a

using namespace std;

int a, b;
int ret;

bool isprim(int n)
{
    if (n < 2) return false;
    for (int i = 2; i <= sqrt(n); i++)
        if (n % i == 0) return false;
    return true;
}

int check(int n)
{
    vector<int> num;
    while (n)
    {
        num.push_back(n % 10);
        n /= 10;
    }

    for (int i = 0; i < num.size(); i++)
        for (int j = 0; j < num.size(); j++)
            if (i != j && num[i] != 0)
                if (isprim(num[i] * 10 + num[j]))
                    return 1;
    return 0;
}

int main()
{
    cin >> a >> b;
    for (int i = max(a, 10); i <= b; i++)
    {
        ret += check(i);
    }

    cout << ret << endl;

    return 0;
}
